import QtQuick
import QtQuick.Controls
import QtQuick.Controls.Basic
import QtQuick.Layouts

Rectangle {
    Layout.fillWidth: true
    Layout.fillHeight: true

    ColumnLayout {
        anchors.fill: parent
        spacing: 10

        // 修改：增加对比文本
        TextArea {
            id: textArea
            Layout.fillWidth: true
            Layout.minimumHeight: 100
            Layout.margins: 10
            textFormat: TextArea.PlainText
            wrapMode: TextArea.Wrap
            text: "<h1>富文本示例</h1><p>这是<b>加粗</b>文本，这是<i>斜体</i>文本。</p><ul><li>列表项1</li><li>列表项2</li></ul>"
        }

        TextArea {
            Layout.fillWidth: true
            Layout.fillHeight: true
            Layout.margins: 10
            textFormat: TextArea.RichText
            wrapMode: TextArea.Wrap
            text: textArea.text

            onTextChanged: {
                if (textFormat === TextEdit.RichText) {
                    console.log("当前内容为富文本格式")
                }
            }
        }
    }
}
